package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentService;
import com.heima.model.common.dtos.CommentDTO;
import com.heima.model.common.dtos.CommentLikeDTO;
import com.heima.model.common.dtos.CommentSaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName CommentController
 * @Description TODO
 * @Author 10725
 * @Date 2021/10/2 22:44
 **/
@RestController
@Api(value = "评论管理API",tags = "评论管理API")
@RequestMapping("/api/v1/comment_repay/like")
public class CommentController {

    @Autowired
    CommentService commentService;

    @ApiOperation("保存评论回复点赞")
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentSaveDTO dto) {
        return commentService.saveComment(dto);
    }


    @ApiOperation("保存评论点赞")
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDTO dto){
        return commentService.like(dto);
    }

    /**
     * 查询评论
     * @param dto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult findByArticleId(@RequestBody CommentDTO dto){
        return commentService.findByArticleId(dto);
    }
}
